#!/bin/bash

COMFYUI_DIR="comfyUI"

git clone https://github.com/comfyanonymous/ComfyUI.git $COMFYUI_DIR
cd $COMFYUI_DIR/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager
git clone https://github.com/AIGODLIKE/AIGODLIKE-ComfyUI-Translation.git
cd ..


python -m venv amdcomfyui
source amdcomfyui/bin/activate

pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm6.0
pip install -r requirements.txt
pip install -r custom_nodes/ComfyUI-Manager/requirements.txt

echo "正在创建 run_amdcomfyui.sh 脚本..."
RUN_SCRIPT="run_amdcomfyui.sh"
if [ ! -f "$RUN_SCRIPT" ]; then
    cat > $RUN_SCRIPT <<EOF
#!/bin/bash
source amdcomfyui/bin/activate
#export HSA_OVERRIDE_GFX_VERSION=10.3.0
export HSA_OVERRIDE_GFX_VERSION=11.0.0
python main.py
EOF
    chmod +x $RUN_SCRIPT
fi

echo "设置和执行完成。"